<?php


namespace app\index\controller;

use GatewayClient\Gateway;
class Push extends Base
{
    /**
     * 医生连接进入
     */
    public function connect()
    {
        $data = $this->request->param();
        Gateway::$registerAddress = config('registerAddress');
        Gateway::bindUid($data['client_id'], $data['u_id']);
    }
    public function pushToUid(){
        $data = $this->request->param();
        Gateway::$registerAddress = config('registerAddress');
        Gateway::sendToUid($data['u_id'], $data['message']);
    }
    public function joinGroup()
    {
        $data = $this->request->param();
        Gateway::$registerAddress = config('registerAddress');
        Gateway::joinGroup($data['client_id'],$data['group']);
    }
    public function pushToGroup(){
        $data = $this->request->param();
        Gateway::$registerAddress = config('registerAddress');
        Gateway::sendToGroup($data['group'], $data['message']);
    }
    public function isUidOnline()
    {
        $req = request();
        $data = $req->param();
        Gateway::$registerAddress = config('registerAddress');
        $d =Gateway::isUidOnline($data['u_id']);
        return json_encode($d);
    }
}